#include<bits/stdc++.h>
using namespace std;
int rd(){
	int ans=0,f=1;char c=getchar();
	while(c<48||c>57){if(c=='-')f=-1;c=getchar();}
	while(c>47&&c<58)ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
	return ans*f;
}
#define f(a,b,c) for(int a=b;a<=c;++a)
#define F(a,b,c) for(int a=b;a>=c;--a)
#define int long long
int d[151515],v[151515],a[151515],p[151515],pre[595959];
//bool R0[151515],L0[151515];
int L[151515],R[151515];
int b[595959];
int pos[151515];
pair<int,int>ne[151515];
int k,k2,k3;
bool cmp(pair<int,int>dfdf,pair<int,int>fdfd){
	if(dfdf.second^fdfd.second)return dfdf.second<fdfd.second;
	return dfdf.first<fdfd.first;
}
int val1(long double x){
	int xx=x;
	if(x-xx<1e-15)return xx-1;
	return xx;
}
int val2(long double x){
	int xx=x;
	if(1-x+xx<1e-15)return xx+2;
	return xx+1;
}
// L,R: The car is too fast in [L,R]
signed main(){
	// freopen("defect.in","r",stdin);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T=rd();
	f(I,1,T){
		int n=rd(),m=rd(),len=rd(),maxv=rd();
		k=0;k2=0;k3=0;
		f(i,1,n){
			d[i]=rd(),v[i]=rd(),a[i]=rd();
			// find the interval where the speed of the car is greater than maxv
			// s.1: the car is decelerating
			if(a[i]<0){
				// if the car is in the limit at the beginning, it will never cross the limit
				if(v[i]>maxv){
					// vt^2-v0^2=2ax -> maxv^2-v[i]^2=2*a[i]*x -> x=(maxv^2-v[i]^2)/2/a[i]
					long double x=(maxv*maxv-v[i]*v[i])/(long double)2/a[i];// displacement
					if(x+d[i]>len)L[++k]=d[i],R[k]=len;//,R0[k]=true;
					else{
						int ll=d[i],rr=val1(x+d[i]);
						if(ll<=rr)L[++k]=ll,R[k]=rr;
					}
				}
			}
			// s.2: the car is moving at a constant speed
			if(a[i]==0)
				if(v[i]>maxv)L[++k]=d[i],R[k]=len;//,L0[k]=R0[k]=true;
			// s.3: the car is accelerating
			if(a[i]>0){
				// if the car is too fast at the beginning, it will always be out of limit
				if(v[i]>maxv)L[++k]=d[i],R[k]=len;//,L0[k]=R0[k]=true;
				// if the car is exactly at the limit at the beginning, it will be out of limit
				// immediately after the beginning
				else if(v[i]==maxv and d[i]+1<=len)L[++k]=d[i]+1/*,L0[k]=false*/,R[k]=len;//,R0[k]=true;
				else{
					// vt^2-v0^2=2ax -> maxv^2-v[i]^2=2*a[i]*x -> x=(maxv^2-v[i]^2)/2/a[i]
					long double x=(maxv*maxv-v[i]*v[i])/(long double)2/a[i];// displacement
					if(x+d[i]<len){
						int ll=val2(x+d[i]),rr=len;
						if(ll<=rr)L[++k]=ll,R[k]=len;
					}
				}
			}
		}
		f(i,1,m)p[i]=rd(),b[++k2]=p[i];
		f(i,1,k)b[++k2]=L[i],b[++k2]=R[i];
		sort(b+1,b+k2+1);
		int sz=unique(b+1,b+k2+1)-(b+1);
		f(i,1,sz)pre[i]=0;
		f(i,1,m)pos[i]=lower_bound(b+1,b+sz+1,p[i])-b,++pre[pos[i]];
		f(i,1,sz)pre[i]+=pre[i-1];
		f(i,1,k){
			int xx=lower_bound(b+1,b+sz+1,L[i])-b;
			int yy=lower_bound(b+1,b+sz+1,R[i])-b;
			//if(!L0[i])++xx;if(!R0[i])--yy;
			if(xx<=yy and pre[yy]!=pre[xx-1])ne[++k3]=make_pair(xx,yy);
		}
		printf("%lld ",k3);
		if(k3==0){
			printf("%lld\n",m);
			continue;
		}
		sort(ne+1,ne+k3+1,cmp);
		int ps=1,ans=0,cps=1,ls=-1;
		while(1){
			while(ps<m and pos[ps+1]<=ne[cps].second)++ps;
			ls=pos[ps];
			++ans;
			while(cps<=k3 and ls>=ne[cps].first)++cps;
			if(cps==k3+1){
				printf("%lld\n",m-ans);
				break;
			}
		}
	}
	return 0;
}
/*
FwdbI5pqQ1fnBj5025s2FtekwHkIZqpnkSM2WBrwDUhMDmNDpFF46ro29WLgL8R3Yn62xvyAPdUcPrnE42GAs2B1ZUfsc7vAuzDpu9xJ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